
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
//1.导入store的实例对象
import store from './store/store.js'
//导入网络请求包
import {$http} from '@escook/request-miniprogram'

Vue.config.productionTip = false

App.mpType = 'app'

uni.$http = $http
//配置请求路径
$http.baseUrl = 'https://www.uinav.com'

$http.beforeRequest = function(options){
  uni.showLoading({
    title:'数据加载中...'
  })
  // 判断请求的是否为有权限的API接口
  if(options.url.indexOf('/my/') !==-1){
   options.header={
     Authorization: store.state.m_user.token,
   }
  }
}

//请求完成之后做的事情
$http.afterRequest = function(){
  uni.hideLoading()
}

//分装弹框方法
uni.$showMsg = function(title = '数据加载失败！',duration=1500){
  uni.showToast({
    title,
    duration,
    icon:'none'
  })
}

const app = new Vue({
    ...App,
    //2.store挂在Vue实例上
    store,
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif